Skip to content

gh-125231: register firefox channels as Mozilla controller#149255

Open
durawat wants to merge 1 commit intopython:mainfrom
durawat:webbrowser-firefox-channels
Open

gh-125231: register firefox channels as Mozilla controller#149255
durawat wants to merge 1 commit intopython:mainfrom
durawat:webbrowser-firefox-channels

Conversation

@durawat
Copy link
Copy Markdown

@durawat durawat commented May 1, 2026

Summary

Detect firefox-* browser channels in PATH.

Details

  • Scans all directories in $PATH for executables matching firefox-*
  • Collects unique channel names (e.g., firefox-dev, firefox-aurora, firefox-beta, firefox-nightly)
  • Register them as Mozilla controller

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 1, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 1, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented May 1, 2026

Documentation build overview

📚 cpython-previews | 🛠️ Build #32515799 | 📁 Comparing 4793972 against main (be9c7cb)

  🔍 Preview build  

2 files changed
± library/webbrowser.html
± whatsnew/changelog.html

@durawat durawat force-pushed the webbrowser-firefox-channels branch from 16ea74c to c7ef872 Compare May 2, 2026 01:04
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 2, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@durawat durawat force-pushed the webbrowser-firefox-channels branch from c7ef872 to 080f2a9 Compare May 2, 2026 01:08
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 2, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Comment thread Doc/library/webbrowser.rst Outdated
Comment thread Lib/webbrowser.py Outdated
@picnixz
Copy link
Copy Markdown
Member

picnixz commented May 3, 2026

This requires a NEWS entry as well.

@picnixz picnixz changed the title gh-125231 register firefox channels as Mozilla controller gh-125231: register firefox channels as Mozilla controller May 3, 2026
@durawat durawat force-pushed the webbrowser-firefox-channels branch from 080f2a9 to 4793972 Compare May 3, 2026 15:11
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 3, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned by the need to look at all directories to locate the valid firefox-* binaries and then add them as recognized binaries. Instead, I would suggest that we look at the BROWSER variable and if the latter contains firefox-* entries, then we recognize them on the fly.

In some sense, we could create a new class called GenericMozilla which is like Mozilla but is matched when the browser has firefox-* prefix. And then the actual binary being used is constructed on demand and cached.

That we only load the browser when we want, not pre-load it. My idea would be to have a separte _browsers_prefixes mapping (like _browsers) but for partial matches. I don't know if I'm clear enough but what I think is not ideal is to preload all existing firefox-* binaries.

how would you solve this specific issue? the proposal here is probably okayish but it's still a huge hammer and we could match binaries that are not meant for opening firefox. For instance, assume you have firefox-not-a-browser which is in your PATH and that you put BROWSER='firefox-not-a-browser'. Should we assume that whatever is in BROWSER is a valid browser or not? if so, we could just directly register the contents of BROWSER that start with firefox- and no glob is needed. Otherwise, we should assume that people using webbrowser must explicitly call register() themselves. For the CLI, we could make this addition automatic via some option.

cc @serhiy-storchaka @sethmlarson for visibility and insights on that topic maybe

+------------------------+-----------------------------------------+-------+
| ``'firefox'`` | ``Mozilla('mozilla')`` | |
+------------------------+-----------------------------------------+-------+
| ``'firefox-'`` | ``Mozilla('mozilla')`` | \(1) |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please adda .. versaionadded entry as (see later in the document)

Comment thread Lib/webbrowser.py
Comment on lines +491 to +496
firefox_channels = {
name
for path_dir in os.environ["PATH"].split(os.pathsep)
for exe in glob.glob(os.path.join(path_dir, "firefox-*"))
if (name := os.path.basename(exe)) and shutil.which(name)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move those checks closer to Mozilla browsers.

Copy link
Copy Markdown
Author

@durawat durawat May 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added them to the end of register_X_browsers due to the concern you had with checking binaries for firefox-*. Since they are pre-release browsers so their try order would be in the end unless BROWSER env is set. Also the reason for glob was that firefox channel names change and aurora is not officially listed now on firefox but available unofficially as rpm package. I was hesistant to use glob.

Comment on lines +197 to +198
firefox-beta, firefox-nightly, etc.
(2)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
firefox-beta, firefox-nightly, etc.
(2)
firefox-beta, firefox-nightly, etc.
(2)

+------------------------+-----------------------------------------+-------+
| ``'firefox'`` | ``Mozilla('mozilla')`` | |
+------------------------+-----------------------------------------+-------+
| ``'firefox-'`` | ``Mozilla('mozilla')`` | \(1) |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| ``'firefox-'`` | ``Mozilla('mozilla')`` | \(1) |
| ``'firefox-*'`` | ``Mozilla('mozilla')`` | \(1) |

Comment thread Lib/webbrowser.py
# firefox-dev, firefox-aurora,firefox-beta, firefox-nightly, etc.
firefox_channels = {
name
for path_dir in os.environ["PATH"].split(os.pathsep)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use os.get_exec_path to list directories with executable paths.

@picnixz
Copy link
Copy Markdown
Member

picnixz commented May 3, 2026

Ok, so to summarize my confusing point:

  • I don't know whether we should have explicitly named firefox browsers.
  • I don't know if loading automatically all firefox-* browsers in the discoverable path is ok. I would say yes? if so, the PR's approach is fine.
  • I don't know if using the programmatic API (via import webbrowser) means leaving registration to the user and only make the CLI autoregister binaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants